//
//  DZZAroundAndHotController.m
//  DZZTravel
//
//  Created by xalo on 16/7/17.
//  Copyright © 2016年 Eason. All rights reserved.
//

#import "DZZAroundAndHotController.h"

@interface DZZAroundAndHotController ()<UITableViewDataSource,UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UIImageView *upImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (strong, nonatomic) IBOutlet UIView *headView;

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (weak, nonatomic) IBOutlet UIView *upView;
@property (weak, nonatomic) IBOutlet UITableView *tableView2;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@property (nonatomic,strong)UIButton *btn1;
@property (nonatomic,strong)UIButton *btn2;
@property (nonatomic,strong)UIView *followView;
@property (nonatomic,strong)UIButton *backBtn;

@property (nonatomic,assign)NSInteger hei;


@property (nonatomic,strong)DZZProductModel *product;
//预定的数组
@property (nonatomic,strong)NSMutableArray *reserveArray;

@property (nonatomic,strong)NSMutableArray *weatherArray;


//Evaluate HeadView的属性

@property (strong, nonatomic) IBOutlet UIView *evaluateHeadView;


@property (weak, nonatomic) IBOutlet UILabel *allLabel;

@property (weak, nonatomic) IBOutlet UILabel *starLabel;

@property (weak, nonatomic) IBOutlet UILabel *numberEvaluateLabel;


@property (weak, nonatomic) IBOutlet UIButton *isPicLabel;
@property (weak, nonatomic) IBOutlet UIButton *goodLabel;

@property (weak, nonatomic) IBOutlet UIButton *middleLabel;

@property (weak, nonatomic) IBOutlet UIButton *badLabel;

//评论模型数组
@property (nonatomic,strong)NSMutableArray *talkArray;

//设置headView的模型
@property (nonatomic,strong)DZZEvaHeadViewModel *model;

@end

@implementation DZZAroundAndHotController

- (NSMutableArray *)talkArray{
    if (!_talkArray) {
        _talkArray = [NSMutableArray array];
    }
    return _talkArray;
}

- (NSMutableArray *)reserveArray{
    if (!_reserveArray) {
        _reserveArray = [NSMutableArray array];
    }
    return _reserveArray;
}




- (NSMutableArray *)weatherArray{
    if (!_weatherArray) {
        _weatherArray = [NSMutableArray array];
    }
    return _weatherArray;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    self.upView.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.scrollView.delegate = self;
    
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBarHidden = YES;
//    注册cell
    [self.tableView registerNib:[UINib nibWithNibName:@"DZZAroundHotCell" bundle:nil] forCellReuseIdentifier:@"DZZAroundHotCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"DZZAdressCell" bundle:nil] forCellReuseIdentifier:@"DZZAdressCell"];
//    tableView2注册
    [self.tableView2 registerNib:[UINib nibWithNibName:@"DZZEvaluateTableViewCell" bundle:nil] forCellReuseIdentifier:@"DZZEvaluateTableViewCell"];
    [self.tableView2 registerNib:[UINib nibWithNibName:@"TableFacViewCell" bundle:nil] forCellReuseIdentifier:@"TableFacViewCell"];
    
    self.tableView2.tableHeaderView = self.evaluateHeadView;
 
//    self.tableView.rowHeight = 70;
//    self.tableView2.rowHeight = 200;
//    加载产品详情信息
    [self LoadData];
    
//     设置评论产品详情按钮
    [self setHotAndAroundPlay];
    
//加载预付
    [self loadReserveData];
    
    [self loadTalkData];
    
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 44, 0);
    self.tableView2.contentInset = UIEdgeInsetsMake(0, 0, 44, 0);
    
}

//设置评论产品详情按钮
- (void)setHotAndAroundPlay{
    UIView *secView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, 64)];
    secView.backgroundColor = [UIColor grayColor];
    self.btn1 = [[UIButton alloc]initWithFrame:CGRectMake(self.view.width/3-60, 27, 40, 30)];
    [self.btn1 setTitle:@"产品" forState:UIControlStateNormal];
    self.followView = [[UIView alloc]initWithFrame:CGRectMake(self.btn1.x, self.btn1.y+self.btn1.height-1, 40, 2)];
    self.followView.backgroundColor = [UIColor orangeColor];
    self.btn2 = [[UIButton alloc]initWithFrame:CGRectMake(self.btn1.x+self.btn1.width+60, 27, 40, 30)];
    
    [self.btn2 setTitle:@"评价" forState:UIControlStateNormal];
    
    self.backBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, self.btn1.y, 40, 30)];
    
    [self.backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.backBtn setTitle:@"返回" forState:UIControlStateNormal];
    
    [self.btn1 addTarget:self action:@selector(btn1Action) forControlEvents:UIControlEventTouchUpInside];
    [self.btn2 addTarget:self action:@selector(btn2Action) forControlEvents:UIControlEventTouchUpInside];
//    设置头部视图
    self.tableView.tableHeaderView = self.headView;
    
    
    [secView addSubview:self.followView];
    [secView addSubview:self.btn1];
    [secView addSubview:self.btn2];
    [secView addSubview:self.backBtn];
    [self.upView addSubview:secView];
    
}

/*
 {
 "data": {
 "productId": 18670,
 "channelLinkId": 101024,
 "productName": "秦岭野生动物园门票",
 "mainTitle": "秦岭野生动物园，亲近自然之旅",
 "subTitle": "自然、清新、朴素的山林野趣，以笼养、散养等多种展出模式，依托秦岭北麓良好的生态环境，实现野生动物大种群保护，展养动物300余种，10000多头（只）。为西北难得的野生动物园。",
 "appMainTitle": "秦岭野生动物园门票",
 "appSubTitle": "多种展出模式，轻享自然山林野趣，认识野生动物世界。",
 "sellPrice": 49,
 "retailPrice": 100,
 "isOnline": true,
 "isActive": true,
 "startDate": "2015-07-06 00:00:00",
 "endDate": "2016-11-30 23:59:59",
 "isExpire": false,
 "openTime": "2004-07-07 00:00:00",
 "goodRate": 5,
 "averageRate": 4.6,
 "commentCount": 5,
 "longitude": "108.874543",
 "latitude": "34.053388",
 "provinceId": 29,
 "provinceName": "陕西",
 "cityId": 289,
 "cityName": "西安",
 "address": "陕西省西安市长安区省道一零七秦岭北麓环山生态旅游带秦岭野生动物园",
 "saledCount": 12784,
 "isCanUseCoupon": true,
 "telphone": "029-89534077",
 "packageDetial": "<div class=\"t-content-taocan\">\n<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【限时活动】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>【7.22-7.23夏季嘉年华专享】含黑纛演出，仅限2016年7月22-23日使用。</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong>【预订限制】</strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>请至少提前1天预订，周末及节假日请尽量提前预订。</li>\n\t<li>【7.22-7.23夏季嘉年华专享】套餐需至少在游玩当天20:00前预订。</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong>【使用方式】</strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>取票方式：请于09:30-15:30，凭收到的兑换券在秦岭野生动物园1号售票窗口换取实体票。</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong>【使用时间】</strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>营业时间：09:00-18:00。</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong>【套餐消费限制】</strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>门票仅供一次使用，请合理安排您的时间。</li>\n</ul>\n</div>\n</div>\n",
 "trafficGuide": "<div class=\"t-content-jt\">\n<h3 class=\"zj\">主要路线</h3>\n\n<ul style=\"padding: 3px 49px;\">\n\t<li style=\"color: #000;\">从咸阳出发：</li>\n\t<li>咸阳市区&rarr;秦皇南路&rarr;陈南路&rarr;连霍高速公路&rarr;帽耳刘立交&rarr;西安绕城高速公路&rarr;京昆高速公路&rarr;丈八立交&rarr;西三环路&rarr;亚迪路&rarr;西太路&rarr;南横线&rarr;G210&rarr;高鸭路&rarr;Y240&rarr;西安秦岭野生动物园。<br />\n\t</li>\n\t<li style=\"color: #000;\">从渭南出发：</li>\n\t<li>渭南市区&rarr;连霍高速公路&rarr;方家村立交&rarr;西安绕城高速公路&rarr;长安立交&rarr;长安南路&rarr;雁环中路&rarr;子午大道&rarr;关中环线&rarr;Y240&rarr;西安秦岭野生动物园。<br />\n\t</li>\n</ul>\n</div>\n",
 "bussinessInfo": null,
 "bookNotice": "",
 "productIntroduction": "<div class=\"t-content-xingcheng\">\n<div style=\" border: 1px dashed #00a2c0; border-radius: 6px; padding: 5px 10px; font-size: 16px; color: #00a2c0; overflow: hidden; zoom: 1; margin-bottom: 20px;\"><span style=\"float: left;\">秦岭野生动物园</span></div>\n\n<ul>\n\t<li><em style=\"display: block; color: #000;\">秦岭野生动物园，乐享野趣</em>秦岭野生动物园位于秦岭北麓浅山地带，是集野生动物移地保护、科普教育、旅游观光、休闲度假等功能于一体的综合性园林项目。这里动物种类齐全，有兽类、鸟类、两栖类和爬行类动物。园区分四个区域，即步行游览区、草食区、猛兽区、鸟语林。并拥有动物表演场、小小动物乐园、游乐场、动物医院、动物检疫场、珍稀动物繁育基地、名花园、快餐厅、咖啡厅、度假村等功能完善、服务一流的配套项目。\n\n\t<p style=\"text-align: center;\"><img alt=\"\" src=\"http://cdn.yaochufa.com/images/productintroduction/85c24c2408df4871a87e42560c7305e4.jpg\" style=\"\" /></p>\n\n\t<p>&nbsp;</p>\n\n\t<p style=\"text-align: center;\"><img alt=\"\" src=\"http://cdn.yaochufa.com/images/productintroduction/f6157f89a2064f9699f19092129d568e.jpg\" style=\"\" /></p>\n\n\t<p>&nbsp;</p>\n\n\t<p style=\"text-align: center;\"><img alt=\"\" src=\"http://cdn.yaochufa.com/images/productintroduction/e1a992b77dde4d59a6091dddbd7772a9.jpg\" style=\"\" /></p>\n\n\t<p>&nbsp;</p>\n\n\t<p style=\"text-align: center;\"><img alt=\"\" src=\"http://cdn.yaochufa.com/images/productintroduction/d10fd627f4814a32bd23a19096735267.jpg\" style=\"\" /></p>\n\n\t<p>&nbsp;</p>\n\n\t<p style=\"text-align: center;\"><img alt=\"\" src=\"http://cdn.yaochufa.com/images/productintroduction/92df525b33c84c20b7c40e26d1cda5f1.jpg\" style=\"\" /></p>\n\n\t<p>&nbsp;</p>\n\n\t<p style=\"text-align: center;\"><img alt=\"\" src=\"http://cdn.yaochufa.com/images/productintroduction/c8d2e0cb818140c48194107f6939a008.jpg\" style=\"\" /></p>\n\t</li>\n</ul>\n</div>\n",
 "recommendTrip": null,
 "recommendTripStr": null,
 "offerInfo": [],
 "facilities": [],
 "imageList": [
 {
 "imageId": 417044,
 "title": "",
 "description": null,
 "url": "http://cdn.yaochufa.com/images/Content960/hl_18670_od_1_723639aeae36462db230016f6040d224.jpg",
 "sortOrder": 1
 },
 {
 "imageId": 417045,
 "title": "",
 "description": null,
 "url": "http://cdn.yaochufa.com/images/Content960/hl_18670_od_1_076a2119f7d94a67b60bb4344d32c1ff.jpg",
 "sortOrder": 2
 },
 {
 "imageId": 417048,
 "title": "",
 "description": null,
 "url": "http://cdn.yaochufa.com/images/Content960/hl_18670_od_1_07d4b35e5e5c48c6b406550ab59060bf.jpg",
 "sortOrder": 3
 },
 {
 "imageId": 417051,
 "title": "",
 "description": null,
 "url": "http://cdn.yaochufa.com/images/Content960/hl_18670_od_1_48b489041cf1402cb248a85cbcb8525e.jpg",
 "sortOrder": 4
 },
 {
 "imageId": 417052,
 "title": "",
 "description": null,
 "url": "http://cdn.yaochufa.com/images/Content960/hl_18670_od_1_b5115c5f9fc143d29189a4f7a307da0e.jpg",
 "sortOrder": 5
 },
 {
 "imageId": 417053,
 "title": "",
 "description": null,
 "url": "images/Content960/hl_18670_od_1_c95605bb130e451fac985d5cf52a9ec8.jpg",
 "sortOrder": 6
 }
 ],
 "videoList": [],
 "weatherInfo": [
 {
 "currentCity": "西安市",
 "pm25": "62",
 "index": [
 {
 "title": "穿衣",
 "zs": "热",
 "tipt": "穿衣指数",
 "des": "天气热，建议着短裙、短裤、短薄外套、T恤等夏季服装。"
 },
 {
 "title": "洗车",
 "zs": "不宜",
 "tipt": "洗车指数",
 "des": "不宜洗车，未来24小时内有雨，如果在此期间洗车，雨水和路上的泥水可能会再次弄脏您的爱车。"
 },
 {
 "title": "旅游",
 "zs": "适宜",
 "tipt": "旅游指数",
 "des": "温度适宜，又有较弱降水和微风作伴，会给您的旅行带来意想不到的景象，适宜旅游，可不要错过机会呦！"
 },
 {
 "title": "感冒",
 "zs": "较易发",
 "tipt": "感冒指数",
 "des": "相对今天出现了较大幅度降温，较易发生感冒，体质较弱的朋友请注意适当防护。"
 },
 {
 "title": "运动",
 "zs": "较不宜",
 "tipt": "运动指数",
 "des": "有降水，推荐您在室内进行健身休闲运动；若坚持户外运动，须注意携带雨具并注意避雨防滑。"
 },
 {
 "title": "紫外线强度",
 "zs": "弱",
 "tipt": "紫外线强度指数",
 "des": "紫外线强度较弱，建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。"
 }
 ],
 "weather_Data": [
 {
 "date": "周一 07月18日 (实时：28℃)",
 "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/xiaoyu.png",
 "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/zhongyu.png",
 "weather": "小雨转中雨",
 "wind": "东风微风",
 "temperature": "28 ~ 23℃"
 },
 {
 "date": "周二",
 "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/zhongyu.png",
 "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/xiaoyu.png",
 "weather": "中雨转小雨",
 "wind": "东风微风",
 "temperature": "26 ~ 21℃"
 },
 {
 "date": "周三",
 "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/duoyun.png",
 "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/qing.png",
 "weather": "多云转晴",
 "wind": "东风微风",
 "temperature": "30 ~ 22℃"
 },
 {
 "date": "周四",
 "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/yin.png",
 "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/yin.png",
 "weather": "阴",
 "wind": "东风微风",
 "temperature": "34 ~ 25℃"
 }
 ]
 }
 ],
 "productTypeText": "门票",
 "star": "",
 "idsTagPropertyTheme": "67,68,72,77;65,476,480,526,534;481"
 },
 "success": true,
 "message": "请求成功",
 "statusCode": 200
 }
 
 */

/*
 
 {
 "data": [
 {
 "miniPrice": 49,
 "retailPrice": 100,
 "tagName": "",
 "isExpand": true,
 "packageInfos": [
 [
 {
 "priceInfo": [],
 "productPackageId": 455118,
 "imageUrl": "group1/M00/02/EF/oYYBAFeHQqyAMRl9AADaiVXf4Go818.jpg",
 "mainItemId": 0,
 "seriesCount": 0,
 "packageName": "【7.22-7.23夏季嘉年华专享】秦岭野生动物园门票1张（含黑纛演出）",
 "miniPrice": 49,
 "retailPrice": 100,
 "outerDescription": "<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【套餐详情】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>秦岭野生动物园门票 1张（含黑纛演出）</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【特别说明】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li><span style=\"color:#ff6600;\">本套餐仅限2016年7月22-23日使用。</span></li>\n\t<li>验票入园时间：周五 16:30-20:00；周六 17:00-20:00；21:00闭园。</li>\n\t<li>黑纛演出时间：19:00开始。</li>\n\t<li>取票方式：请于09:30-15:30，凭收到的兑换券在秦岭野生动物园1号售票窗口换取实体票（前往景区换票需持本人有效学生证验票入园）。</li>\n\t<li>门票仅供一次使用，请合理安排您的时间。</li>\n\t<li>如需加购门票，请自行咨询前台购买。</li>\n</ul>\n</div>\n",
 "packageType": 2,
 "isCanBook": true,
 "isHasInvoice": null,
 "isPreSale": false,
 "preSaleStartDate": null,
 "preSaleEndDate": null,
 "freeBookingStartDate": "",
 "freeBookingEndDate": "",
 "productId": null,
 "channelLinkId": null,
 "sort": 0,
 "itemSetList": [],
 "serviceFacilities": [],
 "isFreeBooking": false,
 "packageFlag": [
 "立减4元"
 ],
 "isPayReturnIntegral": true,
 "itemImages": [
 {
 "itemName": "秦岭野生动物园夏季嘉年华",
 "imageUrl": "group1/M00/02/EF/oYYBAFeHQqyAMRl9AADaiVXf4Go818.jpg"
 }
 ],
 "roomArea": null,
 "bedTypeName": null,
 "bedSize": null,
 "itemFloor": null
 },
 {
 "priceInfo": [],
 "productPackageId": 362260,
 "imageUrl": "images/RoomImage/hl_69944_r_1_f363922b647743f181931e3cb870ea8f.jpg",
 "mainItemId": 0,
 "seriesCount": 0,
 "packageName": "秦岭野生动物园成人票1张",
 "miniPrice": 95,
 "retailPrice": 100,
 "outerDescription": "<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【套餐详情】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>秦岭野生动物园成人票 1张</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【特别说明】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>营业时间：09:00-18:00。</li>\n\t<li>取票方式：请于09:30-15:30，凭收到的兑换券在秦岭野生动物园1号售票窗口换取实体票。</li>\n\t<li>门票仅供一次使用，请合理安排您的时间。</li>\n\t<li>如需加购门票，请自行咨询前台购买。</li>\n</ul>\n</div>\n",
 "packageType": 2,
 "isCanBook": true,
 "isHasInvoice": null,
 "isPreSale": false,
 "preSaleStartDate": null,
 "preSaleEndDate": null,
 "freeBookingStartDate": "",
 "freeBookingEndDate": "",
 "productId": null,
 "channelLinkId": null,
 "sort": 2,
 "itemSetList": [],
 "serviceFacilities": [],
 "isFreeBooking": false,
 "packageFlag": [
 "立减8元"
 ],
 "isPayReturnIntegral": true,
 "itemImages": [
 ***************************************************这个是点击预定之后弹出页面的图片
 {
 "itemName": "秦岭野生动物园成人票",
 "imageUrl": "http://cdn.yaochufa.com/images/RoomImage/hl_69944_r_1_f363922b647743f181931e3cb870ea8f.jpg"
 }
 ],
 "roomArea": null,
 "bedTypeName": null,
 "bedSize": null,
 "itemFloor": null
 },
 {
 "priceInfo": [],
 "productPackageId": 284139,
 "imageUrl": "images/RoomImage/hl_80507_r_1_f1478509cf1e4a4285c723b0e7fe7ef5.jpg",
 "mainItemId": 0,
 "seriesCount": 0,
 "packageName": "西安秦岭野生动物园门票1张+恐龙熊猫馆门票1张",
 "miniPrice": 120,
 "retailPrice": 150,
 "outerDescription": "<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【套餐详情】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>秦岭野生动物园成人票 1张</li>\n\t<li>恐龙熊猫馆门票 1张</li>\n</ul>\n</div>\n\n<div class=\"bottom-height\">\n<h5><strong><span style=\"color:#FF6600;\">【特别说明】</span></strong></h5>\n\n<ul class=\"des1 descolor\">\n\t<li>营业时间：09:00-18:00。</li>\n\t<li>取票方式：请于09:30-15:30，凭收到的兑换券在秦岭野生动物园1号售票窗口换取实体票。</li>\n\t<li>门票仅供一次使用，请合理安排您的时间。</li>\n\t<li>如需加购门票，请自行咨询前台购买。</li>\n</ul>\n</div>\n",
 "packageType": 2,
 "isCanBook": true,
 "isHasInvoice": null,
 "isPreSale": false,
 "preSaleStartDate": null,
 "preSaleEndDate": null,
 "freeBookingStartDate": "",
 "freeBookingEndDate": "",
 "productId": null,
 "channelLinkId": null,
 "sort": 6,
 "itemSetList": [],
 "serviceFacilities": [],
 "isFreeBooking": false,
 "packageFlag": [
 "立减13元"
 ],
 "isPayReturnIntegral": true,
 "itemImages": [
 {
 "itemName": "秦岭野生动物园+恐龙熊猫馆门票",
 "imageUrl": "images/RoomImage/hl_80507_r_1_f1478509cf1e4a4285c723b0e7fe7ef5.jpg"
 }
 ],
 "roomArea": null,
 "bedTypeName": null,
 "bedSize": null,
 "itemFloor": null
 }
 ],
 []
 ],
 "tagIcon": ""
 }
 ],
 "success": true,
 "message": null,
 "statusCode": 200
 }
 
 
 */
/*
 
 
 
 
 
 */

//加载产品
- (void)LoadData{
//    http://appapi.yaochufa.com/v2/Product/GetProductInfoById?system=ios&channel=AppStore&lang=app&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&productId=18670&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&version=5.2.3
//    http://appapi.yaochufa.com/v2/Product/GetProductInfoById?system=ios&channel=AppStore&lang=app&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&version=5.2.3&productId=18670
    [RequestManager fectDataWithUrl:[NSString stringWithFormat:@"http://appapi.yaochufa.com/v2/Product/GetProductInfoById?system=ios&channel=AppStore&lang=app&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&version=5.2.3&productId=%@",self.pID] parameter:@{} method:@"GET" compelet:^(NSData *data) {
    
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        DZZProductModel *model = [[DZZProductModel alloc]init];
        [model setValuesForKeysWithDictionary:dic[@"data"]];
        

        self.product = model;
       
//        if (dic[@"data"][@"weatherInfo"] isEqualToString:)  {
//     
//
//        for (NSDictionary *cicc in dic[@"data"][@"weatherInfo"][0][@"weather_Data"]) {
//            DZZWeatherModel *weather = [[DZZWeatherModel alloc]init];
////
//            [weather setValuesForKeysWithDictionary:cicc];
//            [self.weatherArray addObject:weather];
//        }
//        }
         //    设置头部视图dic[@"data"][@"imageList"][0][@"url"]]
        [self.upImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://cdn.yaochufa.com/%@",dic[@"data"][@"imageList"][0][@"url"]]] placeholderImage:[UIImage imageNamed:@"bs"]];
        
        self.nameLabel.text = [NSString stringWithFormat:@"%@-%@",model.appMainTitle,model.appSubTitle];
        
        
        
        
    } upDateUI:^{
        
       
        
        [self.tableView reloadData];
    }];
    
}
//加载预定数据
- (void)loadReserveData{
//    @"http://appapi.yaochufa.com/v2/ProductPackage/GetCommonPackagesByLinkIdV424?channel=AppStore&checkInDate=2016-07-18&checkOutDate=2016-08-21&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&isSelected=false&lang=app&linkId=175372&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&machineType=0&system=ios&version=5.2.3"
    
    [RequestManager fectDataWithUrl:[NSString stringWithFormat:@"http://appapi.yaochufa.com/v2/ProductPackage/GetCommonPackagesByLinkIdV424?channel=AppStore&checkInDate=2016-07-18&checkOutDate=2016-08-21&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&isSelected=false&lang=app&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&machineType=0&system=ios&version=5.2.3&linkId=%@",self.cID] parameter:@{} method:@"GET" compelet:^(NSData *data) {
    
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        for (NSDictionary *dic2 in dic[@"data"][0][@"packageInfos"][0]) {
            DZZReserveModel *model = [[DZZReserveModel alloc]init];
            [model setValuesForKeysWithDictionary:dic2];
            [self.reserveArray addObject:model];
          
        }
        
        
    } upDateUI:^{
        
        [self.tableView reloadData];
        
    }];
    
    
}


//加载评论详情
- (void)loadTalkData{
    
//    @"http://appapi.yaochufa.com/v2/Comment/GetProductComments?channel=AppStore&commentType=0&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&lang=app&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&machineType=0&pageIndex=1&pageSize=15&system=ios&version=5.2.3&productId=24197"
    
    [RequestManager fectDataWithUrl:[NSString stringWithFormat:@"http://appapi.yaochufa.com/v2/Comment/GetProductComments?channel=AppStore&commentType=0&imei=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&lang=app&machineCode=086DA4DD-1FAB-421A-8AC3-3CF9F2718437&machineType=0&pageIndex=1&pageSize=15&system=ios&version=5.2.3&productId=%@",self.pID] parameter:@{} method:@"GET" compelet:^(NSData *data) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        DZZEvaHeadViewModel *head = [[DZZEvaHeadViewModel alloc]init];
        [head setValuesForKeysWithDictionary:dic[@"data"]];
      
        
        self.model = head;
        
#pragma mark ------------------------------蹦蹦蹦----------------------------------
        if (![dic[@"data"][@"personCount"]  isEqual: @0]) {
            
        
        if ([dic[@"data"][@"commentInfos"] count] >0) {
            
        
        for (NSDictionary *dic2 in dic[@"data"][@"commentInfos"]) {
            DZZEvaluateModel *eva = [[DZZEvaluateModel alloc]init];
            [eva setValuesForKeysWithDictionary:dic2];
            [self.talkArray addObject:eva];
            
        }
        
        }
        }
        
    } upDateUI:^{
        [self setDataHeadView];
        [self.tableView2 reloadData];
        
    }];
    
    
}
//设置第二个TableView的头部视图
- (void)setDataHeadView{

    self.allLabel.text = self.model.averageRate.description;
    self.starLabel.text = @"⭐️⭐️⭐️⭐️⭐️";
    self.numberEvaluateLabel.text = [NSString stringWithFormat:@"%@人评价",self.model.personCount];
   
    
    
    [self.isPicLabel setTitle:self.model.hasPictureCountTip forState:UIControlStateNormal];
    [self.goodLabel setTitle:self.model.goodRateCountTip forState:UIControlStateNormal];
    [self.middleLabel setTitle:self.model.middleRateCountTip forState:UIControlStateNormal];
    [self.badLabel setTitle:self.model.badRateCountTip forState:UIControlStateNormal];
 
    
}

#pragma mark ------------TableViewDelegate--------------------

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (tableView == self.tableView) {
         return self.reserveArray.count+1;
    }
    else{
    return self.talkArray.count;}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView == self.tableView) {
    if (indexPath.row == 0) {
        DZZAdressCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DZZAdressCell"forIndexPath:indexPath];
        ;
        cell.adressLabel.text = self.product.address;
        if (self.weatherArray.count>0) {
            cell.weaterLabel.text = [self.weatherArray[0] weather];
            cell.weaterLabel.text = [NSString stringWithFormat:@"今天 %@ %@",[self.weatherArray[0] temperature],[self.weatherArray[0] weather]];
        }
        return cell;
    }
    else{
        DZZAroundHotCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DZZAroundHotCell" forIndexPath:indexPath];
        if (self.reserveArray.count > 0) {
            
        [cell setCellForModel:self.reserveArray[indexPath.row-1]];

        }
        return cell;
    }}
    else{
       
        if (self.talkArray.count>0 &&[ self.talkArray [indexPath.row]commnentImages].count>0) {
             DZZEvaluateTableViewCell *cell = [self.tableView2 dequeueReusableCellWithIdentifier:@"DZZEvaluateTableViewCell" forIndexPath:indexPath];
            [cell setCellForModel:self.talkArray[indexPath.row]];
         
           NSInteger hei =  [self labelHeightWithText:[self.talkArray [indexPath.row]content] font:[UIFont systemFontOfSize:12]];

                self.hei = hei+80+50+30;

            
           return cell;
        }else{
            
            TableFacViewCell *cell = [self.tableView2 dequeueReusableCellWithIdentifier:@"TableFacViewCell" forIndexPath:indexPath];
            DZZEvaluateModel *evaluate = self.talkArray[indexPath.row];

            
            
            [cell setCellForAModel:evaluate];
            
            NSInteger hei =  [self labelHeightWithText:[self.talkArray [indexPath.row]content] font:[UIFont systemFontOfSize:12]];
             self.hei = hei+90;
            
            return cell;
            
        }
        
        
    }
}
//Label的自适应高度
- (CGFloat)labelHeightWithText:(NSString *)text font:(UIFont *)font{
    
    NSDictionary *dic = @{NSFontAttributeName : font};
    CGRect rect = [text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width, 100000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return rect.size.height;
}



- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView == self.tableView) {
        return 70;
    }
    else{
        return 200;
    }
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView == self.tableView) {
        return 70;
    }
    else{
        return self.hei;
    }
}

//点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (self.tableView == tableView) {
        if (indexPath.row == 0) {
            DZZMapViewController *map = [[DZZMapViewController alloc]init];
            self.navigationController.navigationBarHidden = NO;
            
            map.naviModel = self.product;
            
            
            [self.navigationController pushViewController:map animated:YES];
            
        }
    }
    
    
}



//btn点击事件
- (void)btn1Action{
    [self change:self.btn1];
    [UIView animateWithDuration:0.3 animations:^{
        self.scrollView.contentOffset = CGPointMake(0, 0);
    }];
    
}
- (void)btn2Action{
    
    [self change:self.btn2];
    [UIView animateWithDuration:0.3 animations:^{
        self.scrollView.contentOffset = CGPointMake(kWidth, 0);
    }];
    
}

- (void)backBtnAction{
    
    
    self.navigationController.navigationBarHidden = NO;
    self.upView.hidden = YES;
    [self.navigationController popViewControllerAnimated:YES];
}

//改变btn的方法
- (void)change:(UIButton *)btn{
    CGRect oldRect = self.followView.frame;
    oldRect.size.width = btn.width;
    oldRect.origin.x = btn.x;
    [UIView animateWithDuration:0.25 animations:^{
        self.followView.frame = oldRect;
    }];
}

//分享按钮事件
- (IBAction)shareAction:(id)sender {
    
    
    
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    if (self.scrollView == scrollView) {
        if (self.scrollView.contentOffset.x >= 0.7*kWidth) {
            [self change:self.btn2];
        }if (self.scrollView.contentOffset.x<0.3*kWidth) {
            [self change:self.btn1];
        }
        
    }
    
    
    
    
}


//- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
//    
//  
//    
//}


@end
